package net.chenlin.dp.modules.ticket.manager.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import net.chenlin.dp.common.entity.Page;
import net.chenlin.dp.common.entity.Query;
import net.chenlin.dp.modules.ticket.dao.TicketMapper;
import net.chenlin.dp.modules.ticket.entity.TicketEntity;
import net.chenlin.dp.modules.ticket.manager.TicketManager;

/**
 * 
 * @author ZhouChenglin<yczclcn@163.com>
 */
@Component("ticketManager")
public class TicketManagerImpl implements TicketManager {

	@Autowired
	private TicketMapper ticketMapper;

    /**
     * 分页查询
     * @param page
     * @param search
     * @return
     */
	@Override
	public List<TicketEntity> listTicket(Page<TicketEntity> page, Query search) {
		return ticketMapper.listForPage(page, search);
	}

    /**
     * 新增
     * @param ticket
     * @return
     */
	@Override
	public int saveTicket(TicketEntity ticket) {
		return ticketMapper.save(ticket);
	}

    /**
     * 根据id查询
     * @param id
     * @return
     */
	@Override
	public TicketEntity getTicketById(Long id) {
		TicketEntity ticket = ticketMapper.getObjectById(id);
		return ticket;
	}

    /**
     * 修改
     * @param ticket
     * @return
     */
	@Override
	public int updateTicket(TicketEntity ticket) {
		return ticketMapper.update(ticket);
	}

    /**
     * 删除
     * @param id
     * @return
     */
	@Override
	public int batchRemove(Long[] id) {
		int count = ticketMapper.batchRemove(id);
		return count;
	}

	/**
	 * 获取门票信息
	 * @return
	 */
	@Override
	public List<TicketEntity> selectTickets() {
		return ticketMapper.selectTickets();
	}

	@Override
	public List<TicketEntity> listTicket(String sortby) {
		return ticketMapper.listTicket(sortby);
	}
}
